import axios from 'axios'

const instance = new axios.create({
  baseURL: process.env.REACT_APP_API_URL
});

instance.interceptors.response.use(
  (response) => {
    if (response.data && response.data.errcode === 0) {
      return response.data.data
    } else {
      return Promise.reject(response)
    }
  },
  (error) => {
    return Promise.reject(error)
  }
)

export default instance;